﻿using Edge.Repository.Model.EMS;
using Edge.Repository.Model.EMS.Dto;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace EMSClient.CForm.Uc
{
    public partial class UcAlarmItem : UserControl
    {
        public UcAlarmItem()
        {
            InitializeComponent();
        }

        public UcAlarmItem(EmsAlarmModel data)
        {
            InitializeComponent();
            if (data != null)
            {
                this.label2.Text = data.AlarmTime.ToString("yyyy-MM-dd");
                this.label3.Text = data.AlarmTime.ToString("HH:mm:ss");

                if (!string.IsNullOrEmpty(data.RecordData))
                {
                    EquipRecordDto record = Newtonsoft.Json.JsonConvert.DeserializeObject<EquipRecordDto>(data.RecordData);
                    if (record != null)
                    {
                        if (record.IsQingQi) { panel2.Visible = true; label5.Text = record.QingQiVal; }
                        else { panel2.Visible = false; }

                        if (record.WenDuList != null && record.WenDuList.Count > 0)
                        {
                            foreach (var item in record.WenDuList)
                            {
                                UcJianCe uc = new UcJianCe("温度" + item.Index, item.Val);
                                flowLayoutPanel1.Controls.Add(uc);
                            }
                        }

                        if (record.ShiDuList != null && record.ShiDuList.Count > 0)
                        {
                            foreach (var item in record.ShiDuList)
                            {
                                UcJianCe uc = new UcJianCe("湿度" + item.Index, item.Val);
                                flowLayoutPanel2.Controls.Add(uc);
                            }
                        }
                    }
                }
            }
        }
        public UcAlarmItem(bool istest)
        {
            InitializeComponent();
            if (1 == 1)
            {
                this.label2.Text = DateTime.Now.ToString("yyyy-MM-dd");
                this.label3.Text = DateTime.Now.ToString("HH:mm:ss");


                EquipRecordDto record = new EquipRecordDto(); ;
                if (record != null)
                {
                    panel2.Visible = true; label5.Text = "xxxx";
                    List<EquipVal> WenDuList = new List<EquipVal>();

                    for (int i = 1; i <= 15; i++)
                    {
                        WenDuList.Add(new EquipVal() { Index = i, Val = "XXXX" }); ;
                    }

                    foreach (var item in WenDuList)
                    {
                        UcJianCe uc = new UcJianCe("温度" + item.Index, item.Val);
                        flowLayoutPanel1.Controls.Add(uc);
                    }

                    foreach (var item in WenDuList)
                    {
                        UcJianCe uc = new UcJianCe("湿度" + item.Index, item.Val);
                        flowLayoutPanel2.Controls.Add(uc);
                    }

                }

            }
        }

        private void panel5_Paint(object sender, PaintEventArgs e)
        {
            ControlPaint.DrawBorder(e.Graphics, panel5.ClientRectangle,
                        Color.DimGray, 1, ButtonBorderStyle.None, //左边
                   Color.DimGray, 1, ButtonBorderStyle.None, //上边
                   Color.DimGray, 1, ButtonBorderStyle.Solid, //右边
                   Color.DimGray, 1, ButtonBorderStyle.None);//底边
        }

        private void panel6_Paint(object sender, PaintEventArgs e)
        {
            ControlPaint.DrawBorder(e.Graphics, panel5.ClientRectangle,
                  Color.DimGray, 1, ButtonBorderStyle.None, //左边
             Color.DimGray, 1, ButtonBorderStyle.None, //上边
             Color.DimGray, 1, ButtonBorderStyle.Solid, //右边
             Color.DimGray, 1, ButtonBorderStyle.None);//底边
        }

        private void label1_Paint(object sender, PaintEventArgs e)
        {
            ControlPaint.DrawBorder(e.Graphics, label1.ClientRectangle,
            Color.DimGray, 1, ButtonBorderStyle.None, //左边
       Color.DimGray, 1, ButtonBorderStyle.None, //上边
       Color.DimGray, 1, ButtonBorderStyle.Solid, //右边
       Color.DimGray, 1, ButtonBorderStyle.None);//底边
        }

        private void label6_Paint(object sender, PaintEventArgs e)
        {
            ControlPaint.DrawBorder(e.Graphics, label1.ClientRectangle,
       Color.DimGray, 1, ButtonBorderStyle.None, //左边
  Color.DimGray, 1, ButtonBorderStyle.None, //上边
  Color.DimGray, 1, ButtonBorderStyle.Solid, //右边
  Color.DimGray, 1, ButtonBorderStyle.None);//底边
        }
    }
}
